package com.education.welco.controller.app;


import com.education.common.core.BaseController;
import com.education.common.utils.ApiReturnObject;
import com.education.welco.pojo.SCatalogPreview;
import com.education.welco.service.ISCatalogPreviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 课程预习 信息操作处理
 *
 * @author d
 * @date 2020-05-08
 */
@Api(tags = {"APP-学校课程--预习"})
@RestController
@RequestMapping("/app/sCatalogPreview")
public class AppSCatalogPreviewController extends BaseController {


    @Autowired
    private ISCatalogPreviewService catalogPreviewService;

    @ApiOperation(value = "学校课程--预习接口", httpMethod = "GET")
    @GetMapping("/selectByPreview")
    public ApiReturnObject selectByPreview(Integer catalogId, Integer classId) {
        if (null != catalogId) {
            SCatalogPreview catalogPreview = new SCatalogPreview();
            catalogPreview.setCatalogId(catalogId);
            catalogPreview.setClassId(classId);
            catalogPreview.setIsStu("1");//是否允许学生查看 1 是 0 否
            List<SCatalogPreview> catalogPreviewList = catalogPreviewService.selectSCatalogPreviewList(catalogPreview);
            return new ApiReturnObject("200","查询成功",catalogPreviewList.size(),catalogPreviewList);
        } else {
            return new ApiReturnObject("201", "catalogId为空", "catalogId为空");
        }
    }

}